
import { cateList } from '@/request/api'
//声明state
const state = {
    list: []  //菜单列表
}

//修改state
const mutations = {
    changeList(state, arr) {
        state.list = arr
    }
}


const actions = {
    listActions(context) {
        //发起分类列表请求
        cateList({ istree: true }).then(res => {
            // console.log(res);
            if (res.code === 200) {
                context.commit('changeList', res.list)
            }
        })
    },

}


//派生状态
const getters = {
    list(state) {
        return state.list
    }
}


export default {
    state,
    mutations,
    actions,
    getters,
    namespaced: true,   //启用命名空间
}